package com.zsy.service.impl;

import cn.hutool.json.JSONObject;
import com.zsy.mapper.IContractMapper;
import com.zsy.websocket.MyWebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class websocket {
    @Autowired
    private MyWebSocketServer webSocketServer;

    @Autowired
    private IContractMapper iMp;

    public String websocketService(String muName){
        JSONObject jsonMessage = new JSONObject(muName);
        String username = jsonMessage.getStr("username");
        String content = jsonMessage.getStr("message");

        String Approval_status = jsonMessage.getStr("Approval_status");
        //判断是否在线
        //boolean userOnline = webSocketServer.isUserOnline(username);

        //存入数据库
        iMp.insertWebCk(username, content);
        webSocketServer.sendMessage(muName);

        return muName;
    }
//    public String webaaa(){
//
//        return "数据";
//    }

}
